<!--
*@description 
*@fileName 平台药品库（非医保）
*@author wxl
*@date 2025/02/15 15:29:11
!-->
<template>
   <div class="vue-box cdf">
      <div class="search-card">
         <div class="title">平台药品库（非医保）</div>
         <div class="search-body">
            <el-form :inline="true" :model="formData" class="demo-form-inline">
               <el-form-item label="医疗目录编码">
                  <el-input v-model="formData.MIC_Code" placeholder="请输入"  />
               </el-form-item>
               <el-form-item label="注册名称">
                  <el-input v-model="formData.ItemName" placeholder="请输入"  />
               </el-form-item>
               <el-form-item label="条形码">
                  <el-input v-model="formData.barCode" placeholder="请输入"  />
               </el-form-item>
               <el-form-item label="商品分类">
                  <el-input v-model="formData.DrugsClassification" placeholder="请输入"  />
               </el-form-item>
               <el-form-item label="生产企业名称">
                  <el-input v-model="formData.EnterpriseName" placeholder="请输入"  />
               </el-form-item>
               <el-form-item label="批准文号">
                  <el-input v-model="formData.ApprovalNumber" placeholder="请输入"  />
               </el-form-item>
               <el-form-item>
                  <el-button class="btn" type="primary" @click="onSearch">搜索</el-button>
                  <!-- <el-button class="btn" type="primary" plain @click="onSearch">导出</el-button> -->
               </el-form-item>
            </el-form>
         </div>
      </div>
      <div class="c-card flex1 table-box">
         <div class="table-top">
            <div>汇总数量：{{ pagin.total }} </div>
            <div>截至时间：{{ pagin.server_time || '-'}}</div>
         </div>
         <div class="table-body">
            <el-table :data="tableData" stripe style="width: 100%;overflow: auto;" max-height="100%">
                <!-- 第一列显示序号 -->
               <el-table-column
                  label="序号"
                  type="index"
                  width="55"
                  align="center"
               ></el-table-column>
               <el-table-column v-for="(item, index) in tableCfg" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
                  <template #default="scope">
                     <span>
                        {{ item.formatter ? item.formatter(scope.row[item.prop]) : scope.row[item.prop] }}
                     </span>
                  </template>
               </el-table-column>
            </el-table>
         </div>
         <table-pagin :page-no="pagin.pageNo" :page-size="pagin.pageSize" :total="pagin.total" @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" />
      </div>
   </div>
</template>
<script setup name="goods-list">
import { reactive,onMounted, ref } from 'vue'
import {useRouter} from 'vue-router'
import tablePagin from '@/sa-frame/com/pagin/table-pagin.vue'

const router = useRouter()
const formData = reactive({
   name: '',
})
const pagin = reactive({
   pageNo: 1,
   pageSize: 10,
   total: 0,
   server_time: ''
})

const tableCfg = ref([{
   label: '注册名称',
   prop: 'ItemName',
   width: '140px'
}, {
   label: '药品编码',
   prop: 'ItemCode',
   width: '270px'
}, {
   label: '注册剂型',
   prop: 'RegDosform'
}, {
   label: '规格',
   prop: 'Spec'
}, {
   label: '生产企业名称',
   prop: 'EnterpriseName',
   width: '180px'
}, {
   label: '批准文号',
   prop: 'ApprovalNumber'
}, {
   label: '条形码',
   prop: 'barCode'
}])

const tableData = ref([])

// 组件加载时触发
onMounted(() => {
    f5();
})

// 搜索
function onSearch() {
   pagin.pageNo = 1
   f5()
}

// ------------------ 查找数据 ------------------
const f5 = function() {
   let params = {
      pageindex: pagin.pageNo - 1,
      pagesize: pagin.pageSize,
      ...formData
   }
   sa.ajax('/api/fund/merchantStoreDrugDataList', params, function(res) {
      tableData.value = res.data;	// 数据
      pagin.total = Number(res.totalItems);
      pagin.server_time = res.server_time
   });
};
// 表格页码切换
function handleCurrentChange(pageNo) {
   pagin.pageNo = pageNo
   console.log(' pagin.pageNo',pagin.pageNo)
   f5()
}
// 表格size修改
function handleSizeChange(pageSize) {
   pagin.pageSize = pageSize
   f5()
}
// 下单
function createOrder(row) {
   console.log(row)
   router.push({
      name: 'create-order',
      query: {
         GoodsNo: row.GoodsNo
      }
   }).then(res => {
    
   })
}

// 对外开放函数 
defineExpose({f5})
</script>
<style lang="scss" scoped></style>
